package cn.iocoder.yudao.module.pickbook.controller.app.auth;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.pickbook.controller.app.auth.vo.PickbookAuthLoginRespVO;
import cn.iocoder.yudao.module.pickbook.controller.app.auth.vo.PickbookAuthWeixinLoginReqVO;
import cn.iocoder.yudao.module.pickbook.service.auth.PickbookAuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "绘本用户 APP - 认证")
@RestController
@RequestMapping("/pickbook/app/auth")
@Validated
@Slf4j
public class PickbookAppAuthController {

    @Resource
    private PickbookAuthService authService;

    @PostMapping("/weixin-login")
    @Operation(summary = "微信小程序登录")
    @PermitAll
    public CommonResult<PickbookAuthLoginRespVO> weixinLogin(@RequestBody @Valid PickbookAuthWeixinLoginReqVO reqVO) {
        return success(authService.weixinLogin(reqVO));
    }

    @PostMapping("/logout")
    @Operation(summary = "登出")
    public CommonResult<Boolean> logout(@RequestParam("token") String token) {
        authService.logout(token);
        return success(true);
    }

} 